package com.swak.boot.config.jdbc.mapper;

import javax.sql.DataSource;

import org.mybatis.spring.mapper.MapperFactoryBean;
import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

import com.swak.boot.config.jdbc.DataSourceAutoConfiguration;
import com.swak.boot.config.jdbc.database.DruidDataSourceAutoConfiguration;
import com.swak.boot.config.jdbc.database.HikariDataSourceAutoConfiguration;
import com.swak.boot.config.jdbc.database.SqlLiteDataSourceAutoConfiguration;
import com.swak.boot.config.jdbc.sharding.ShardingJdbcConfiguration;

@Configuration
@ConditionalOnBean(DataSource.class)
@Import(MybatisMapperScannerRegistrar.class)
@ConditionalOnMissingBean({ MapperFactoryBean.class, MapperScannerConfigurer.class })
@ConditionalOnClass({ MapperFactoryBean.class, MapperScannerConfigurer.class })
@AutoConfigureAfter({DataSourceAutoConfiguration.class, ShardingJdbcConfiguration.class,
    SqlLiteDataSourceAutoConfiguration.class, DruidDataSourceAutoConfiguration.class,
    HikariDataSourceAutoConfiguration.class})
public class MybatisMapperAutoConfiguration {

}